function log(val){
    console.log(val);
}
var vm = new Vue({
    el: "#app",

    data: {
        items: [],
        itemsLen: '',
        MenuList: [],
        totalPageNum: [],
        pageSize: '',
        currentPageNum: '',
    },

    filters: {
    },

    computed: {
    },

    mounted: function(){
        //this.showList();
        this.getMenuList();
        this.getPager();
    },

    methods: {
        showList: function(){
            this.$http.get("/api/User/getList").then(function(data){
                this.items = data.data.data;
                this.itemsLen = data.data.data.length;
            });
        },
        member_stop: function(item, id){
            $.ajax({
                type: 'POST',
                url: '/api/User/memberStop',
                dataType: 'json',
                data : {
                    id : id
                },
                success: function(data){
                    item.state = 0;
                    layer.msg('已停用!',{icon: 5,time:1000});
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        },
        member_start: function(item, id){
            $.ajax({
                type: 'POST',
                url: '/api/User/memberStart',
                dataType: 'json',
                data : {
                    id : id
                },
                success: function(data){
                    item.state = 1;
                    layer.msg('已启用!',{icon: 6,time:1000});
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        },
        getMenuList: function(){
            var url = window.location.href;
            url = url.substring(url.indexOf("/", 8), url.length);
            this.$http.get("/Menu/getRoot", {'url' : url}).then(function(data){
                this.MenuList = data.data.data;
            });
        },
        getPager: function(n){
            this.$http.get("/api/User/page",{pageNum : n, pageSize : this.pageSize}).then(function(data){
                this.totalPageNum = data.data.totalPageNum;
                this.pageSize = data.data.perPageSize;
                this.currentPageNum = data.data.currentPageNum;
                this.items = data.data.entitys;
            });
        },
        back: function(){
            if(this.currentPageNum != 1){
                this.$http.get("/api/User/page",{pageNum : this.currentPageNum - 1, pageSize : this.pageSize}).then(function(data){
                    this.totalPageNum = data.data.totalPageNum;
                    this.pageSize = data.data.perPageSize;
                    this.currentPageNum = data.data.currentPageNum;
                    this.items = data.data.entitys;
                });
            }
        },
        go: function(){
            if(this.currentPageNum<this.totalPageNum){
                this.$http.get("/api/User/page",{pageNum : this.currentPageNum + 1, pageSize : this.pageSize}).then(function(data){
                    this.totalPageNum = data.data.totalPageNum;
                    this.pageSize = data.data.perPageSize;
                    this.currentPageNum = data.data.currentPageNum;
                    this.items = data.data.entitys;
                });
            }
        }
    }
});